package com.hrzyit.whistle.cases.widgets

import android.content.Context
import com.hrzyit.base.ext.onClick
import com.hrzyit.whistle.cases.R
import com.hrzyit.whistle.cases.data.bean.CaseApplyCloseVo
import com.hrzyit.whistle.cases.presenter.CaseInfoPresenter
import com.lxj.xpopup.animator.PopupAnimator
import com.lxj.xpopup.core.CenterPopupView
import kotlinx.android.synthetic.main.popup_case_accept.view.*

/**
 * 弹出窗口：案件申请结案界面
 * @author YangWei
 * @date 2019/4/21
 */
class CaseApplyClosePopup (context: Context,val presenter: CaseInfoPresenter): CenterPopupView(context) {

    lateinit var caseApplyCloseVo: CaseApplyCloseVo

    // 返回自定义弹窗的布局
    override fun getImplLayoutId(): Int {
        return R.layout.popup_case_apply_close
    }

    // 执行初始化操作，比如：findView，设置点击，或者任何你弹窗内的业务逻辑
    override fun onCreate() {
        super.onCreate()
        // 获取数据不受理原因
//        caseSignInVo.let{
//            mReasonDescEt.setText("${it.reasonDesc}")
//        }
        mConfirmBtn.onClick{
//            context.toast("${mReasonDescEt?.text}")
            mReasonDescEt?.let {
                val info = if (it.text.isNotBlank()) {it.text} else {""}
                caseApplyCloseVo.desc = "$info"
            }
            presenter.applyCaseClose(caseApplyCloseVo)
        }
        mCancelBtn.onClick{
            dismiss() // 关闭弹窗
        }
    }

    // 设置最大宽度，看需要而定
    override fun getMaxWidth(): Int {
        return super.getMaxWidth()
    }

    // 设置最大高度，看需要而定
    override fun getMaxHeight(): Int {
        return super.getMaxHeight()
    }

    // 设置自定义动画器，看需要而定
    override fun getPopupAnimator(): PopupAnimator {
        return super.getPopupAnimator()
    }
}